From 5077f717d32f9c6c45469d83e688ea1abc329db8 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Tue, 23 Oct 2018 21:22:03 -0500 Subject: [PATCH] New includeme() configuration callable --- setup.py | 5 ++++- .../{pgwui_common.py => configure.py} | 19 ++++++++++++++--- ...test_pgwui_common.py => test_configure.py} | 21 ++++++++++++++++--- 3 files changed, 38 insertions(+), 7 deletions(-) rename src/pgwui_common/{pgwui_common.py => configure.py} (61%) rename tests/{test_pgwui_common.py => test_configure.py} (60%) diff --git a/setup.py b/setup.py index 75c84d1..cb3feea 100644 --- a/setup.py +++ b/setup.py @@ -131,7 +131,10 @@ setup( package_dir={'': 'src'}, # Run-time dependencies. - install_requires=[], + install_requires=[ + 'pyramid_beaker', + 'pyramid_mako', + ], # List additional groups of dependencies here (e.g. development # dependencies). You can install these using the following syntax, diff --git a/src/pgwui_common/pgwui_common.py b/src/pgwui_common/configure.py similarity index 61% rename from src/pgwui_common/pgwui_common.py rename to src/pgwui_common/configure.py index 205c4eb..52c820f 100644 --- a/src/pgwui_common/pgwui_common.py +++ b/src/pgwui_common/configure.py @@ -19,9 +19,22 @@ # Karl O. Pinc -'''Empty module. +'''Provide a way to configure PGWUI. + +To use pgwui_common configure your pyramid app by putting the +following into your package's __init__.py: + + from pyramid.config import Configurator + + def main(global_config, **settings): + config = Configurator() + config.include('pgwui_common.configure.includeme') + ''' -def example_func(): - return 1 +def includeme(config): + config.include('pyramid_mako') + config.include('pyramid_beaker') + config.add_static_view( + 'static', 'pgwui_common:/static', cache_max_age=3600) diff --git a/tests/test_pgwui_common.py b/tests/test_configure.py similarity index 60% rename from tests/test_pgwui_common.py rename to tests/test_configure.py index c0fca96..ca4eaa6 100644 --- a/tests/test_pgwui_common.py +++ b/tests/test_configure.py @@ -19,8 +19,23 @@ # Karl O. Pinc -from pgwui_common import pgwui_common +from pgwui_common import configure -def test_example_func(): - assert pgwui_common.example_func() == 1 +def test_configure_includecalled(): + + class MockConfig(): + def __init__(self): + self.include_called = False + self.add_static_view_called = False + + def include(self, *args): + self.include_called = True + + def add_static_view(self, *args, **kwargs): + self.add_static_view_called = True + + config = MockConfig() + configure.includeme(config) + assert config.include_called + assert config.add_static_view_called -- 2.34.1